import 'package:flutter/material.dart';

/// 应用颜色配置
/// App color configuration
class AppColors {
  // 私有构造函数，防止实例化
  // Private constructor to prevent instantiation
  AppColors._();

  // ==================== 浅色主题颜色 Light Theme Colors ====================
  
  /// 主色调 - 雾紫色
  /// Primary color - Misty purple
  static const Color primary = Color(0xFF9C88D4);
  
  /// 次要色调 - 淡蓝色
  /// Secondary color - Light blue
  static const Color secondary = Color(0xFF7FB3D3);
  
  /// 强调色 - 柔和粉色
  /// Accent color - Soft pink
  static const Color accent = Color(0xFFE8B4CB);
  
  /// 背景色 - 奶白色
  /// Background color - Cream white
  static const Color background = Color(0xFFFAF9F7);
  
  /// 表面色 - 纯白色
  /// Surface color - Pure white
  static const Color surface = Color(0xFFFFFFFF);
  
  /// 浅表面色
  /// Light surface color
  static const Color surfaceLight = Color(0xFFF8F8F8);
  
  /// 错误色 - 柔和红色
  /// Error color - Soft red
  static const Color error = Color(0xFFE57373);
  
  /// 成功色 - 柔和绿色
  /// Success color - Soft green
  static const Color success = Color(0xFF81C784);
  
  /// 警告色 - 柔和橙色
  /// Warning color - Soft orange
  static const Color warning = Color(0xFFFFB74D);
  
  /// 信息色 - 柔和蓝色
  /// Info color - Soft blue
  static const Color info = Color(0xFF64B5F6);
  
  // ==================== 文字颜色 Text Colors ====================
  
  /// 主要文字颜色
  /// Primary text color
  static const Color onPrimary = Color(0xFFFFFFFF);
  
  /// 次要文字颜色
  /// Secondary text color
  static const Color onSecondary = Color(0xFFFFFFFF);
  
  /// 表面文字颜色
  /// Surface text color
  static const Color onSurface = Color(0xFF2D2D2D);
  
  /// 背景文字颜色
  /// Background text color
  static const Color onBackground = Color(0xFF2D2D2D);
  
  /// 禁用文字颜色
  /// Disabled text color
  static const Color textDisabled = Color(0xFF9E9E9E);
  
  /// 次要文字颜色
  /// Secondary text color
  static const Color textSecondary = Color(0xFF757575);
  
  /// 第三级文字颜色
  /// Tertiary text color
  static const Color textTertiary = Color(0xFF9E9E9E);
  
  /// 错误文字颜色
  /// Error text color
  static const Color onError = Color(0xFFFFFFFF);
  
  // ==================== 边框和分割线颜色 Border and Divider Colors ====================
  
  /// 边框颜色
  /// Outline color
  static const Color outline = Color(0xFFE0E0E0);
  
  /// 通用边框颜色
  /// General border color
  static const Color border = Color(0xFFE5E7EB);
  
  /// 阴影颜色
  /// Shadow color
  static const Color shadowColor = Color(0x1A000000);

  /// 主要文本颜色
  /// Primary text color
  static const Color textPrimary = Color(0xFF212121);
  
  /// 边框颜色别名
  /// Border color alias
  static const Color borderColor = Color(0xFFE0E0E0);
  
  /// 阴影颜色
  /// Shadow color
  static const Color shadow = Color(0x1A000000);
  
  // ==================== 深色主题颜色 Dark Theme Colors ====================
  
  /// 深色主题 - 主色调
  /// Dark theme - Primary color
  static const Color primaryDark = Color(0xFFB39DDB);
  
  /// 深色主题 - 次要色调
  /// Dark theme - Secondary color
  static const Color secondaryDark = Color(0xFF90CAF9);
  
  /// 深色主题 - 强调色
  /// Dark theme - Accent color
  static const Color accentDark = Color(0xFFF8BBD9);
  
  /// 深色主题 - 背景色
  /// Dark theme - Background color
  static const Color backgroundDark = Color(0xFF121212);
  
  /// 深色主题 - 表面色
  /// Dark theme - Surface color
  static const Color surfaceDark = Color(0xFF1E1E1E);
  
  /// 深色主题 - 错误色
  /// Dark theme - Error color
  static const Color errorDark = Color(0xFFEF5350);
  
  /// 深色主题 - 成功色
  /// Dark theme - Success color
  static const Color successDark = Color(0xFF66BB6A);
  
  /// 深色主题 - 警告色
  /// Dark theme - Warning color
  static const Color warningDark = Color(0xFFFF9800);
  
  /// 深色主题 - 信息色
  /// Dark theme - Info color
  static const Color infoDark = Color(0xFF2196F3);
  
  // ==================== 深色主题文字颜色 Dark Theme Text Colors ====================
  
  /// 深色主题 - 主要文字颜色
  /// Dark theme - Primary text color
  static const Color onPrimaryDark = Color(0xFF000000);
  
  /// 深色主题 - 次要文字颜色
  /// Dark theme - Secondary text color
  static const Color onSecondaryDark = Color(0xFF000000);
  
  /// 深色主题 - 表面文字颜色
  /// Dark theme - Surface text color
  static const Color onSurfaceDark = Color(0xFFE0E0E0);
  
  /// 深色主题 - 背景文字颜色
  /// Dark theme - Background text color
  static const Color onBackgroundDark = Color(0xFFE0E0E0);
  
  /// 深色主题 - 错误文字颜色
  /// Dark theme - Error text color
  static const Color onErrorDark = Color(0xFFFFFFFF);
  
  // ==================== 深色主题边框和分割线颜色 Dark Theme Border and Divider Colors ====================
  
  /// 深色主题 - 边框颜色
  /// Dark theme - Outline color
  static const Color outlineDark = Color(0xFF424242);
  
  /// 深色主题 - 阴影颜色
  /// Dark theme - Shadow color
  static const Color shadowDark = Color(0xFF000000);
  
  // ==================== 情绪颜色 Emotion Colors ====================
  
  /// 快乐情绪颜色
  /// Happy emotion color
  static const Color emotionHappy = Color(0xFFFFD54F);
  
  /// 悲伤情绪颜色
  /// Sad emotion color
  static const Color emotionSad = Color(0xFF81C784);
  
  /// 愤怒情绪颜色
  /// Angry emotion color
  static const Color emotionAngry = Color(0xFFE57373);
  
  /// 焦虑情绪颜色
  /// Anxious emotion color
  static const Color emotionAnxious = Color(0xFFFFB74D);
  
  /// 平静情绪颜色
  /// Calm emotion color
  static const Color emotionCalm = Color(0xFF81C784);
  
  /// 兴奋情绪颜色
  /// Excited emotion color
  static const Color emotionExcited = Color(0xFFFF8A65);
  
  /// 疲惫情绪颜色
  /// Tired emotion color
  static const Color emotionTired = Color(0xFF9E9E9E);
  
  /// 困惑情绪颜色
  /// Confused emotion color
  static const Color emotionConfused = Color(0xFFBA68C8);
  
  /// 感激情绪颜色
  /// Grateful emotion color
  static const Color emotionGrateful = Color(0xFFA5D6A7);
  
  /// 孤独情绪颜色
  /// Lonely emotion color
  static const Color emotionLonely = Color(0xFF90A4AE);
  
  // ==================== 渐变色 Gradient Colors ====================
  
  /// 主要渐变色
  /// Primary gradient
  static const List<Color> primaryGradient = [
    Color(0xFF9C88D4),
    Color(0xFF7FB3D3),
  ];
  
  /// 次要渐变色
  /// Secondary gradient
  static const List<Color> secondaryGradient = [
    Color(0xFF7FB3D3),
    Color(0xFFE8B4CB),
  ];
  
  /// 背景渐变色
  /// Background gradient
  static const List<Color> backgroundGradient = [
    Color(0xFFFAF9F7),
    Color(0xFFFFFFFF),
  ];
  
  /// 卡片渐变色
  /// Card gradient
  static const List<Color> cardGradient = [
    Color(0xFFFFFFFF),
    Color(0xFFF8F8F8),
  ];
  
  /// 情绪渐变色
  /// Emotion gradient
  static const List<Color> emotionGradient = [
    Color(0xFFE8B4CB),
    Color(0xFF9C88D4),
    Color(0xFF7FB3D3),
  ];
  
  // ==================== 透明度变体 Opacity Variants ====================
  
  /// 获取主色调的透明度变体
  /// Get primary color with opacity
  static Color primaryWithOpacity(double opacity) => primary.withOpacity(opacity);
  
  /// 获取次要色调的透明度变体
  /// Get secondary color with opacity
  static Color secondaryWithOpacity(double opacity) => secondary.withOpacity(opacity);
  
  /// 获取强调色的透明度变体
  /// Get accent color with opacity
  static Color accentWithOpacity(double opacity) => accent.withOpacity(opacity);
  
  /// 获取表面色的透明度变体
  /// Get surface color with opacity
  static Color surfaceWithOpacity(double opacity) => surface.withOpacity(opacity);
  
  // ==================== 工具方法 Utility Methods ====================
  
  /// 根据情绪类型获取对应颜色
  /// Get color by emotion type
  static Color getEmotionColor(String emotionType) {
    switch (emotionType.toLowerCase()) {
      case 'happy':
        return emotionHappy;
      case 'sad':
        return emotionSad;
      case 'angry':
        return emotionAngry;
      case 'anxious':
        return emotionAnxious;
      case 'calm':
        return emotionCalm;
      case 'excited':
        return emotionExcited;
      case 'tired':
        return emotionTired;
      case 'confused':
        return emotionConfused;
      case 'grateful':
        return emotionGrateful;
      case 'lonely':
        return emotionLonely;
      default:
        return primary;
    }
  }
  
  /// 根据强度获取颜色透明度
  /// Get color opacity by intensity
  static double getIntensityOpacity(int intensity) {
    return (intensity / 10.0).clamp(0.3, 1.0);
  }
  
  /// 获取对比色（用于文字显示）
  /// Get contrast color for text display
  static Color getContrastColor(Color backgroundColor) {
    // 计算亮度
    // Calculate brightness
    double brightness = (backgroundColor.red * 299 + 
                        backgroundColor.green * 587 + 
                        backgroundColor.blue * 114) / 1000;
    
    // 根据亮度返回黑色或白色文字
    // Return black or white text based on brightness
    return brightness > 128 ? onSurface : surface;
  }
  
  /// 获取柔和的阴影颜色
  /// Get soft shadow color
  static Color getSoftShadowColor(bool isDark) {
    return isDark ? shadowDark.withOpacity(0.3) : shadow.withOpacity(0.1);
  }
  
  /// 获取果冻质感的颜色变体
  /// Get jelly-like color variant
  static Color getJellyColor(Color baseColor, {double opacity = 0.8}) {
    return baseColor.withOpacity(opacity);
  }
}